#If one were to add this file and it's text file to a share drive, they could schedule a task to run this on all # computers within a security group to check if a specific process is running. # Instantiates variables for processes, SN, and lookFor $processes = $SN = '' [String]$lookFor = 'svchost.exe' # <---- Enter processes name here. # Sets the Enviornment Variable value for each variable on line 2 $processes = (Get-WmiObject -Class Win32_Process).Name $SN = (Get-ChildItem Env:COMPUTERNAME).Value # If $lookFor is found within $process if ($processes.Contains($lookFor)) { # Adds SN to a text file. Add-Content -Path 'filepath' -Value $SN # Prints the SN to console. Write-Host 'Found lookFor process: ' $lookFor 'on ' $SN } else { # If not found, prints the following: Write-Host 'Process not running' }